# -*- coding: utf-8 -*-
"""
Created on Sat Sep 12 16:41:00 2020

@author: wangshuo
"""

import matplotlib.pyplot as plt
import numpy as np

plt.axis([-10,150,100,-10])
plt.axis('on')
plt.grid(True)

p0=np.mat([0,0,1]).T
p1=np.mat([60,0,1]).T
p2=np.mat([60,60,1]).T

p_x=[p0[0,0],p1[0,0],p2[0,0],p0[0,0]]
p_y=[p0[1,0],p1[1,0],p2[1,0],p0[1,0]]

plt.plot(p_x,p_y,color='g')

'''
平移矩阵
'''
t_x=15
t_y=10

t_move=np.mat([[1,0,t_x],[0,1,t_y],[0,0,1]])

p0_move=np.dot(t_move,p0)
p1_move=np.dot(t_move,p1)
p2_move=np.dot(t_move,p2)

p_x_move=[p0_move[0,0],p1_move[0,0],p2_move[0,0],p0_move[0,0]]
p_y_move=[p0_move[1,0],p1_move[1,0],p2_move[1,0],p0_move[1,0]]
plt.plot(p_x_move,p_y_move,color='r')

'''
旋转矩阵
'''
theta=pi/3

t_rotate=np.mat([[cos(theta),-sin(theta),0],[sin(theta),cos(theta),0],[0,0,1]])
p0_rotate=np.dot(t_rotate,p0)
p1_rotate=np.dot(t_rotate,p1)
p2_rotate=np.dot(t_rotate,p2)

p_x_rotate=[p0_rotate[0,0],p1_rotate[0,0],p2_rotate[0,0],p0_rotate[0,0]]
p_y_rotate=[p0_rotate[1,0],p1_rotate[1,0],p2_rotate[1,0],p0_rotate[1,0]]
plt.plot(p_x_rotate,p_y_rotate,color='b')


plt.show()



